<template>
  <div class="contain">
    <div class="table-content">
      <template>
        <el-table
          :data="tableData"
          style="width: 100%">
          <el-table-column
            prop="intYM"
            label="月份"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="orderTypeText"
            label="订单类型"
            align="center">
          </el-table-column>
          <el-table-column
            prop=""
            label="操作"
            align="center">
            <template slot-scope="scope">
              <el-button @click="handleCreate(scope.row.rentalId, scope.row.intYM, scope.row.orderType)" type="primary" size="small">创建订单</el-button>
            </template>
          </el-table-column>
        </el-table>
      </template>
    </div>

  </div>
</template>
<script>
  let CONSTANT = require("../../constant/constant.js");
  let common = require("../../common.js");
  export default{
    data(){
      return {
        tableData: [],
      }
    },
    components: {
      'table-list':() => import('../common/my-table')
    },
    created() {
      this.identify = sessionStorage.getItem("identify");
    },
    mounted() {
      this.getList()
    },
    methods: {
      getList(){
        let url = CONSTANT.URL.L_ORDER.NEWORDER;
        common.requestAjax(url, {}, {rentalId: this.$router.currentRoute.query.id}, (data) => {
          if (data.status == 200) {
            this.tableData = data.data.bussData
          }
        })
      },
      handleCreate(id, date, type) {
        let url = CONSTANT.URL.L_ORDER.CREATE;
        common.requestAjax(url, {}, {rentalId: id, orderType: type, intYM: date}, (data) => {
            if (data.status == 200) {
              this.$message({
                type: "success",
                message: data.msg
              })
              this.$router.push("/orderDetail?id="+data.data.bussData+"&pub=1")
            } else {
              this.$message({
                type: "warning",
                message: data.msg
              })
              setTimeout( () => {
                this.$router.push("/readout")
              }, 2000)

            }
        })
      },
    },
  }
</script>

<style lang="scss">
  .contain {
    .el-dialog__body{ padding-left: 0;padding-top: 30px;border-top:1px solid #dedede;}
    .dialog-con{
      background-color: #f5f5f5;
      display: flex;
      justify-content: space-between;
      ul{
        width:28%;list-style: none;padding:0;font-size:14px;float: left;margin-top:0;z-index:999;
        li{ list-style: none;height:60px;line-height:60px;text-align: center;display: block;}
        li.active{color:#21b5cc;background-color: #fff;font-size:16px;border-right:2px solid #21b5cc;}
        //   li:hover{font-size:16px; }
      }
      .tab-content{ width: 70%;display: inline-block;padding-left:10%;background-color: #fff;min-height:300px;
        .sort{
          .sort_name{ font-weight: 600;margin-bottom: 5px;}
          .group-list{ padding-left: 20px;
            .el-radio{display:block;margin-left: 0;margin-bottom: 3px;}
          }
        }
      }
      .el-button--default{background-color: #fff !important;}
    }
  }
</style>
